load("//tools/build_defs/oss:soloader_defs.bzl", "fb_core_android_library", "fb_java_library")

fb_core_android_library(
    name = "soloader",
    proguard_config = "soloader.pro",
    provided_deps = [
        "//deps:jsr_305",
    ],
    required_for_source_only_abi = True,
    visibility = [
        "PUBLIC",
    ],
    exported_deps = [
        ":annotation",
        ":loader",
    ],
)

LOADER_SRCS = glob(
    ["*.java"],
    exclude = [
        "MergedSoMapping.java",
        "DoNotOptimize.java",
    ],
)

fb_core_android_library(
    name = "loader",
    srcs = LOADER_SRCS,
    proguard_config = "soloader.pro",
    provided_deps = [
        ":annotation",
        "//deps:jsr_305",
    ],
    required_for_source_only_abi = True,
    visibility = ["PUBLIC"],
    deps = [
        ":mapping-stub",
        "//java/com/facebook/soloader/nativeloader:nativeloader",
        # Be very careful adding new dependencies here, because this code
        # has to run very early in the app startup process.
        # Definitely do *not* depend on guava.
    ],
)

# For aar building, we want almost all deps to be provided.
fb_core_android_library(
    name = "loader_for_aar",
    srcs = LOADER_SRCS,
    provided_deps = [
        ":annotation",
        "//deps:jsr_305",
        "//java/com/facebook/soloader/nativeloader:nativeloader",
    ],
    visibility = ["PUBLIC"],
    deps = [
        ":mapping-stub",
    ],
)

fb_java_library(
    name = "mapping-stub",
    srcs = ["MergedSoMapping.java"],
    provided_deps = [
        "//deps:jsr_305",
    ],
)

fb_java_library(
    name = "annotation",
    srcs = ["DoNotOptimize.java"],
    required_for_source_only_abi = True,
    visibility = [
        "PUBLIC",
    ],
)
